package cn.rayfoo.common.config;

import com.baomidou.mybatisplus.extension.plugins.OptimisticLockerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * @author rayfoo@qq.com
 * @version 1.0
 * <p>配置MyBatisPlus</p>
 * @date 2020/8/17 10:58
 */
@EnableTransactionManagement
@MapperScan("cn.rayfoo.modules.*.mapper")
@Configuration
public class MyBatisPlusConfig {

    /***************
     * 注册乐观锁插件 *
     ***************/
    @Bean
    public OptimisticLockerInterceptor optimisticLockerInterceptor(){
        return new OptimisticLockerInterceptor();
    }

    /***********
     * 分页插件 *
     ***********/
    @Bean
    public PaginationInterceptor paginationInterceptor() {
        return new PaginationInterceptor();
    }

}
